import java.util.LinkedList;
import java.util.List;

public class Board {
	int width = 7;
	int height = 6;
	boolean whiteMove = true;
	private enum Tiles {
		Empty,
		Red,
		White
	}
	private Tiles[][] board = new Tiles[width][height];
	
	public Board() {
		for (int x = 0; x < width; x++) {
			for (int y = 0; y < height; y++) {
				board[x][y] = Tiles.Empty;
			}
		}
	}
		
	public Board nextBoard(int lastDrop) {
		Board nextBoard = new Board();
		nextBoard.whiteMove = !whiteMove;
		for (int x = 0; x < width; x++) {
			for (int y = 0; y < height; y++) {
				nextBoard.board[x][y] = board[x][y];
			}
		}
						
		for (int y = 0; y < height; y++) {
			if (nextBoard.board[lastDrop-1][y] == Tiles.Empty) {
				if (whiteMove) {
					nextBoard.board[lastDrop-1][y] = Tiles.White;
				}
				else {
					nextBoard.board[lastDrop-1][y] = Tiles.Red;
				}
				return nextBoard;
			}
		}
		return null;
	}
	
	public List<Integer> legalCollumns() {
		List<Integer> collumns = new LinkedList<Integer>();
		for (int i = 0; i < width; i++) {
			if (board[i][height-1] == Tiles.Empty) {
				collumns.add(i+1);
			}
		}
		return collumns;
	}
}
